'''
Created on 22.12.2011

@author: hkh
'''
from numpy import *
from scipy.interpolate import interp1d
from scipy import interpolate
from matplotlib import *

import matplotlib.pyplot as plt

print 'shit2'

t = array([0.00, 0.02, 0.04, 0.08, 0.17, 0.25, 0.51, 0.76, 1.02, 0.88, 1.52, 4.09, 5.21, 8.05, 9.80])
y = array([0.0369, 0.0395, 0.0418, 0.0433, 0.0433, 0.0442, 0.0440, 0.0437, 0.0435, 0.0345, 0.0371, 0.0485, 0.0721, 0.0771, 0.0768])

f1 = interp1d(t, y)
f2 = interp1d(t, y, kind='cubic')

xnew = linspace(0, 9.8, 1000)
#print xnew

#plt.plot(xnew,f2(xnew))
#plt.show()

plt.plot(t,y,'o',xnew,f1(xnew),'-', xnew, f2(xnew),'--')
plt.legend(['data', 'linear', 'cubic'], loc='best')
plt.show()

tck = interpolate.splrep(t,y,s=0)
xxnew = arange(0, 9.8, 100)
tnew = interpolate.splev(xxnew,tck,der=0)

plt.plot(xxnew,tnew)
plt.show()